﻿namespace Sai.Test.Sandcastle
{
    using Sai.Core.Sandcastle;
    using Sai.Test.XUnit;
    using Xunit;

	public class ProjectItemFacts
	{
		public class TheLineMatchesMethod
		{
			
			[Fact, InMemoryTest]
			public void Returns_False_For_Empty_String()
			{
				Assert.False(ProjectItem.LineMatches(string.Empty));
			}

			
			[Fact, InMemoryTest]
			public void Returns_False_For_Unmatched_String()
			{
				Assert.False(ProjectItem.LineMatches("<Folder Include=\"Help\" />"));
			}

			
			[Fact, InMemoryTest]
			public void Returns_True_For_Matched_String()
			{
				Assert.True(ProjectItem.LineMatches("<Content Include=\"Help.aml\" />"));
			}

			
			[Fact, InMemoryTest]
			public void Returns_True_For_Matched_Whitespace_String()
			{
				Assert.True(ProjectItem.LineMatches("\t   <Content     \t  Include=\"Help.aml\" />"));
			}

			
			[Fact, InMemoryTest]
			public void Returns_True_For_ContentLayout_Matched_String()
			{
				Assert.True(ProjectItem.LineMatches("<ContentLayout Include=\"Help.content\" />", ProjectItem.ContentLayoutTag));
			}
			
			
			[Fact, InMemoryTest]
			public void Returns_True_For_ContentLayout_Matched_Whitespace_String()
			{
				Assert.True(ProjectItem.LineMatches("\t   <ContentLayout     \t  Include=\"Help.content\" />", ProjectItem.ContentLayoutTag));
			}
		}

		public class TheParseMethod
		{
			
			[Fact, InMemoryTest]
			public void Finds_Path_For_ContentLayout()
			{
				string line = "\t   <ContentLayout     \t  Include=\"Help.content\" />";

				ProjectItem item = new ProjectItem();
				item.Parse(line);

				Assert.Equal("Help.content", item.Path);

			}
		}

		public class TheToStringMethod
		{
			
			[Fact, InMemoryTest]
			public void In_Format_Content_Include_FileName()
			{
				ProjectItem item = new ProjectItem("Index.html");

				Assert.Equal("<Content Include=\"Index.html\" />", item.ToString());
			}
		}
	}
}
